from codex import * from time import sleep import math import random #trying to establish circle color change have so many circles def show_random_circle(): num = random.randrange(10) display.show(pics.CIRCLE[num]) display.print("Can you draw a flower") sleep(1) display.clear() #indicating the center value for x and y CENTER=120 color=RED #create a center line (y axis) display.fill(BLACK) #vertical line display.draw_line(0, CENTER, 105, CENTER,WHITE) display.draw_line(CENTER, 105, CENTER, 0,WHITE) # display.draw_line(135,CENTER,239,CENTER,WHITE) display.draw_line(CENTER,135,CENTER,239,WHITE) x=CENTER while True: val=accel.read() #get only the x value tilt_x=val[0] tilt_y=val[1] #scale x val scaledx=(tilt_x/16384) scaledy=(tilt_y/16384) #max and min values scaledx=min(max(scaledx,-1), 1) scaledy=min(max(scaledy,-1), 1) #calculate the degrees degreesx=math.asin(scaledx)*180/math.pi degreesy=math.asin(scaledy)*180/math.pi #integer degreesx =int(degreesx) degreesy =int(degreesy) #establish center of circle x=CENTER+degreesx y=CENTER+degreesy #erase old circle display.draw_circle(x,CENTER,15,color) #input the circle #trying to get the color of the circle to change once x=60 and y=60 display.draw_circle(x,y,15,color) if x>60 and y>60: color=YELLOW sleep(0.2)